package com.example.eda.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class LoginEventConfig {

    // 登录事件交换机
    @Bean
    public TopicExchange loginExchange() {
        return new TopicExchange("login_exchange");
    }

    // 登录事件队列
    @Bean
    public Queue loginQueue() {
        return new Queue("login_queue");
    }

    // 绑定关系
    @Bean
    public Binding loginBinding(Queue loginQueue, TopicExchange loginExchange) {
        return BindingBuilder.bind(loginQueue)
                .to(loginExchange)
                .with("login.routing.key");
    }
}

